package com.xqx.thread.initial;

/**
 * 调用了线程的join方法，
 */
public class ThreadNoJoin {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("主线程运行开始");
        ThreadTest thread1=new ThreadTest("A");
        ThreadTest thread2=new ThreadTest("B");
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println("主线程运行结束");
    }
}

/*
class ThreadTest extends Thread{
    public String name;
    public ThreadTest(String name){
        super(name);
        this.name=name;
    }

    @Override
    public void run() {
        System.out.println(ThreadTest.currentThread().getName()+"线程运行开始!");
        for (int i = 0; i < 5; i++) {
            System.out.println("子线程"+name+"运行："+i);
            try {
                sleep((int)Math.random()*10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println(ThreadTest.currentThread().getName()+"线程运行结束!");
    }
}*/
